home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / FredFish PD 314.adf / Zc / zcsrc.lzh / IOLib / stdio / gets.c < prev    next >
C/C++ Source or Header  |  1988-11-09  |  322b  |  22 lines

  1. #include <stdio.h>
  2.  
  3. char *gets(data)
  4.     register char *data;
  5.     {
  6.     register char *p = data;
  7.     register int c;
  8.  
  9.     while(((c = fgetc(stdin)) != EOF) && (c != '\n'))
  10.         {
  11.         if(c == '\b')
  12.             {
  13.             if(p > data)
  14.                 --p;
  15.             }
  16.         else
  17.             *p++ = c;
  18.         }
  19.     *p = '\0';
  20.     return(((c == EOF) && (p == data)) ? NULL : data);  /* NULL == EOF */
  21.     }
  22.